package it.asvp.asvp_portal.data.dao.impl;

import it.asvp.asvp_portal.data.dao.CouncilDao;
import it.asvp.asvp_portal.data.entity.member.Council;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class CouncilDaoImpl extends GenericDaoImpl<Long, Council> implements CouncilDao {

  // private static final Log log = LogFactory.getLog(CouncilDaoImpl.class);

  @Override
  @SuppressWarnings("unchecked")
  public List<Council> findByYear(Integer startYear, Integer endYear) {

    Criteria cr = getSession().createCriteria(Council.class);
    cr.add(Restrictions.eq("startYear", startYear));
    cr.add(Restrictions.eq("endYear", endYear));
    List<Council> list = (List<Council>) cr.list();
    return list;
  }

  @Override
  @SuppressWarnings("unchecked")
  public List<Council> getCurrent() {

    Criteria cr = getSession().createCriteria(Council.class);
    cr.add(Restrictions.eq("current", true));
    List<Council> list = (List<Council>) cr.list();
    return list;
  }

}
